package top.cardone.security.shiro.func;

import lombok.Setter;
import org.apache.shiro.SecurityUtils;
import top.cardone.core.util.func.Func0;
import top.cardone.core.util.func.Func1;

import java.util.Map;

/**
 * Created by yht on 16-3-28.
 */
public class ReadValueFunc implements Func0<Object>, Func1<Object, Map<String, Object>> {
    @Setter
    private Object key;

    @Override
    public Object func() {
        Object attribute = SecurityUtils.getSubject().getSession().getAttribute(this.key);

        return attribute;
    }

    @Override
    public Object func(Map<String, Object> stringObjectMap) {
        return this.func();
    }
}
